package com.example.KeHuDuan;

import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import com.example.client.SocketClient;

public class WiFi extends BaseActivity implements View.OnClickListener {
    private static final String TAG = "WiFi";
    private boolean IsConnectedWIFI = true;
    SocketClient socketClient ;  //SocketClient类

    Button testButton,connectButton;

    @Override
    protected void sendHandlerToService() {

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_wifi);
        Button back = (Button) findViewById(R.id.back);
        testButton = (Button) findViewById(R.id.test_Button);
        connectButton = (Button) findViewById(R.id.connect_Button);
        back.setOnClickListener(this);
        testButton.setOnClickListener(this);
        connectButton.setOnClickListener(this);
    }

    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.back:
                Intent backIntent = new Intent(WiFi.this, MainActivity.class);
                startActivity(backIntent);
                this.finish();
                break;
            case R.id.connect_Button:
                //判断是否连接成功WIFI，连接成功则开始socket连接
                if(IsConnectedWIFI == true){
                    mServiceBinder.connect();
                } else {
                    Log.d(TAG, "onCreate: WiFi连接失败");
                }
                break;
            case R.id.test_Button:

                mServiceBinder.test();
                break;
            default:
                break;
        }
    }
}
